define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_getbannerlist(result) {
			if(true) {
				result = '{"success": true,"msg": "","result": {"associate": [' +
						'{"associate_id": 1,"associate_type": "type_A","image_id": "./img/upload/siwper-img00.png","d_order": 1},' +
						'{"associate_id": 2,"associate_type": "type_A","image_id": "./img/upload/siwper-img01.png","d_order": 2},' +
						'{"associate_id": 2,"associate_type": "type_A","image_id": "./img/upload/siwper-img02.png","d_order": 3}' +
						']},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_detail(result) {
			if(true) {
				result = '{"success": true,"msg": "","result": ' +
						'{"act_id": "001","name": "促销","start_time": "2017/01/01 09:00:00","end_time": "2017/02/01 09:00:00","create_group": true,"has_packets": true,"video_type": "1","image": [{"id": "001","image": ""},{"id": "002","image": ""}],"brand_id": "001","cat_type": [{"id": "001"},{"id": "002"}]},' +
						'"session": "7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		function get_data_promotion_view(result){
			if(true){
				result = '{"success":true,"msg":"","result":{"act_id":"001","act_name":"促销活动","start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","group_id":"123456789","introduction":"双十一促销。","image":[{"id":"001","image":"./img/upload/siwper-img00.png"},{"id":"002","image":"./img/upload/siwper-img02.png"},{"id":"003","image":"./img/upload/siwper-img02.png"}],"deal_count":145,"deal_money":"5698.12","goods_count":567,"attention_count":2356},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			}else
			return result;
		}
		function get_data_goods_list(result){
			if(true){
				result = '{"success":true,"msg":"","result":{"store_count":"500","data":[{"goods_id":1,"name":"十字螺丝刀","introduce":"十字螺丝刀","price":5.5,"mktprice":8,"preprice":5.5,"store_id":"WuJin_1","store_name":"五金一店","image":"./img/upload/pro-img01.jpg","storenumber":100,"salenumber":20,"personlimit":3,"qq":"1234567","phone":"18912345678"},{"goods_id":2,"name":"一字螺丝刀","introduce":"一字螺丝刀","price":5.5,"mktprice":8,"preprice":5.5,"store_id":"WuJin_1","store_name":"五金一店","image":"./img/upload/pro-img01.jpg","storenumber":80,"salenumber":10,"personlimit":3,"qq":"1234567","phone":"18912345678"}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			}else
			return result;
		}
		//返回信息
		return {
			//获取轮播图
			getbannerlist: function(callback) {
				Http.post({
						method: 'homepage.banner.getbannerlist',
						picSize: 'CS',
						pagelimit: 8,
						nPage: 1
					},
					function(result) {
						//请求成功
						if(callback)
							callback(get_data_getbannerlist(result).result);
					},
					function(e) {
						//请求异常
					},
					function() {
						//请求完成，一般不做什么事情
					}
				);
			},
			//获取详细数据
			promotion_view:function(act_id,callback){
				Http.post({
					method:'marketing.promotion.view',
					act_id:act_id
				},function(result){
					if(callback)
					callback(get_data_promotion_view(result).result);
				},function(e){
					
				},function(){
					
				})
			},
			goods_list:function(nPage,callback,calldone){
				Http.post({
					method:'goods.search.getlist',
					cat_type:4,
					key:'',
					pagelimit:8,
					nPage:nPage,
					orderby:'',
					picSize:'',
					region:'',
					store_cat:'',
					act_id:'',
					recommend_id:''
				},function(result){
					if(callback)
					callback(get_data_goods_list(result).result);
				},function(e){
					
				},function(){
					if(calldone)
					calldone();
				})
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Productextentdetail", factory);
});